

import React from 'react'

let scaleName = {
    c:"摄氏度",
    v:"华氏度"
}
class temperatureInput extends React.Component{
    
    handleInputChange=(e)=>{
        // console.log(e.target.value);
        //结构父级组件通过props传递下来的函数，并且进行回调
        let {handleChange} = this.props
        // console.log(this.props);
        handleChange(e.target.value)
        
    }
                render(){
                    //结构props的值
                    let {scale,temperature} = this.props
                    return(
                        <fieldset>
                            <legend>{scaleName[scale]}</legend>
                            <input type="text" value={temperature}  onChange ={this.handleInputChange} />
                        </fieldset>
                    )
                }
            }
export default temperatureInput